package com.xxyuan.batch._11_step_condition_decider;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
import org.springframework.batch.core.job.flow.JobExecutionDecider;

import java.util.Random;

public class MyStatusDecider implements JobExecutionDecider {
    /**
     * 执行过程中返回指定的状态值
     * @param jobExecution
     * @param stepExecution
     * @return
     */
    @Override
    public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {

        System.out.println("--------------------------------------------------");
        long ret = new Random().nextInt(3);
        if (ret==0){
            return new FlowExecutionStatus("A");
        }else if (ret==1){
            return new FlowExecutionStatus("B");
        }else {
            return new FlowExecutionStatus("C");
        }
    }
}
